#include <stdlib.h> 
#include <stdio.h> 
#include <time.h>
#include <assert.h>

long fsize(FILE* fp)
{
  long pos_set, pos_end;
  
  assert(fp != NULL);

  fseek(fp, 0L, SEEK_SET);
  pos_set = ftell(fp);
  
  fseek(fp, 0L, SEEK_END);
  pos_end = ftell(fp);

  return pos_end - pos_set;
}


int main(void)
{
  int i,j;
  FILE* fp;
  char ch = '\n';
  
  fp = fopen("test.txt", "wb+");

  assert(fp != NULL);
  
  // printf("RAND_MAX: %d", RAND_MAX);
  srand((unsigned)time(NULL));
  for(i = 0; i < 10000; i++){
    j = rand();
    // printf("%d\t", j);
    fwrite(&j, sizeof(int), 1, fp);
    fwrite(&ch, sizeof(char), 1, fp);
    
  }

  // printf("\n%ld\n", fsize(fp));

  // fseek(fp, 0L, SEEK_SET);
  
/*   for(i = 0; i < 10; i++) */
/*   { */
/*     fread(&j, sizeof(int), 1, fp); */
/*     printf("%d\t", j); */
/*   } */
  
  fclose(fp);
  
  return 0;
}


